# Maintainer: Díaz Urbaneja Diego <sodomon2@gmail.com>
# Contributor: Díaz Urbaneja Diego <sodomon2@gmail.com>
pkgname=lua-crypt
pkgver=1.0.0
pkgrel=0
pkgdesc="A crypt(3)-style module for Lua. Brings its own implementations, entirely independent of your local libc"
url="https://github.com/jprjr/lua-crypt"
arch="all"
license="MIT"
options="!check" # make check not implemented
source="lua-crypt-$pkgver.tar.gz::https://github.com/jprjr/lua-crypt/archive/$pkgver.tar.gz"

_luaversions="5.1 5.2 5.3 5.4"
for _v in $_luaversions; do
	makedepends="$makedepends lua$_v-dev"
	subpackages="$subpackages lua$_v-${pkgname#lua-}:_package"
done

prepare() {
	default_prepare

	local lver; for lver in $_luaversions; do
		cp -r "$builddir" "$builddir-$lver"
	done
}

build() {
	local lver; for lver in $_luaversions; do
		msg "Building for Lua $lver..."
		cd "$builddir-$lver"
		make LUA=lua$lver
	done
}

package() {
	mkdir -p "$pkgdir"
}

_package() {
	local lver="${subpkgname:3:3}"
	pkgdesc="$pkgdesc (for Lua $lver)"
	depends="lua$lver"
	install_if="$pkgname=$pkgver-r$pkgrel lua$lver"

	mkdir -p "$subpkgdir"
	cd "$builddir-$lver"
	mkdir -p "$subpkgdir"/usr/lib/lua/$lver/crypt
	mkdir -p "$subpkgdir"/usr/share/lua/$lver
	cp -a crypt.lua "$subpkgdir"/usr/share/lua/$lver
	cp -a crypt/core.so "$subpkgdir"/usr/lib/lua/$lver/crypt/
}



sha512sums="a3e488c60c622a5635fe6ce1c835e7cb0d9bd04c7b14416f4ea69af890b651c84f4fced2e5bdf08090d074cabb21253badd8e4ee34fbce135d4ce69353396fcf  lua-crypt-1.0.0.tar.gz"
